package de.barny.main;

import java.util.ArrayList;
import java.util.List;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.LabelBuilder;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;

public class WorkerList extends VBox {

	int listWidth = 100;
	int listHeight = 300;
	
	List<Worker> workers;
	
	public WorkerList() {
		this.setPrefWidth(listWidth);
		this.setSpacing(20);
		this.setPadding(new Insets(50, 0, 20, 0));
		workers = new ArrayList<Worker>();
		
		drawWorkerList();
	}
	
	private void drawWorkerList() {
		for (int i = 0; i < 5; i++) {
			drawWorkerAvatar("Jenny", "Michel");
		}
	}
	
	private void drawWorkerAvatar(String name, String surname) {
		VBox avatar = new VBox();
		avatar.setPrefSize(100, 80);
		
		Image picture = new Image("de/barny/main/res/user.png");
		ImageView picView = new ImageView(picture);
		picView.setTranslateX(25);
		
		Label nameLabel = LabelBuilder.create().text(name + surname).build();
		nameLabel.setAlignment(Pos.CENTER);
		nameLabel.setPrefWidth(100);
		
		avatar.getChildren().add(picView);
		avatar.getChildren().add(nameLabel);
		this.getChildren().add(avatar);
	}
	
	public void addWorker(String name, String surname) {
		workers.add(new Worker(name, surname));
	}
	
	public void removeWorker(String name, String surname) {
		workers.remove(new Worker(name, surname));
	}
	
	public void setBoxHeight(int h) {
		listHeight = h;
		this.setHeight(h);
	}
	
}
